﻿<%@ WebHandler Language="C#" Class="Cell" %>

using System;
using System.Web;
using System.Data;
using System.Data.OracleClient;

public class Cell : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        string arg = context.Request.QueryString["arg"];
        string organ = context.Request.QueryString["organ"];
        string sqlStr = "SELECT * FROm (select CELL_CHNAME from CELL_CLASS WHERE CELL_CHNAME LIKE '%" 
            + Tools.ReplaceString(arg,50) + "%' ";
        if (!organ.Equals("0"))
        {
            sqlStr += " AND CELL_CHNAME LIKE '" + organ + "%' ";
        }
        sqlStr += ") A WHERE rownum <=10  ORDER BY  rownum";
        DataTable dt = OracleHelper.ExecuteDataSet(sqlStr, CommandType.Text, null).Tables[0];        
        context.Response.ContentType = "application/json";
        context.Response.Write(Tools.DataTableToJson(dt));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}